-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ipfs metadata provider #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment :)
} catch (error: unknown) { | ||
if (error instanceof InvalidContentException) throw error; | ||
|
||
if (axios.isAxiosError(error)) { | ||
console.warn(`Failed to fetch from ${url}: ${error.message}`); | ||
} else { | ||
console.error(`Failed to fetch from ${url}: ${error}`); | ||
} | ||
} | ||
} | ||
|
||
console.error(`Failed to fetch IPFS data for CID ${ipfsCid} from all gateways.`); | ||
return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we need a tailored error handling
- Non existent content should return undefined
- Network and other errors should retry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open question: Could it happen that some content of a cid exist in one gateway and not in other ?
In other words, can we be sure that a cid content doesn't exist in some way ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's an interesting question, i have to research since i don't know much about IPFS
regarding the first:
- non existent returns undefined after checking and failing on all the gateways
- yeah totally, i left a TODO for working the retry policy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tldr; it's possible that a CID "exists" on one gateway and not on another if the content hasn't propagated to the node corresponding to that gateway:
https://www.perplexity.ai/search/you-re-an-expert-on-ipfs-and-i-WA60t4oLT46rc1yZySnJkg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! After addressing the comments it'd be good to go for me.
throw new InvalidCidException(ipfsCid); | ||
} | ||
|
||
for (const gateway of this.gateways) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if latency here is super important but, if it is, have you considered using Promise.any
? You'll always be triggering N requests but resolving with the first successful one, instead of calling them sequentially until one of them succeeds.
It could be also helpful to quickly handle non-existant CIDs if, for some reason, you expect working with non-existant CIDs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that could be super helpful but maybe at the same time we exhaust all of the gateways when not needed to 🤔 , like i said to kenji, i will read more about IPFS cuz i know little
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will go back into this analysis when implementing the retry policy, for now we keep this simpler solution for the MVP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Same comments as the others
🤖 Linear
Closes GIT-65
Description
metadata
package with IpfsProviderChecklist before requesting a review